version 14
set more off

***************************************************************************************************
* THIS ROUTINE GENERATES FIGURE A.IV OF WASEEM (2019) RESTAT
***************************************************************************************************

use				"$project_data\ExemptionCutoff_06_11.dta",clear
keep			if employee==0
sort			regnor year
local 			var="seinc"
local			lbound=80000
local			ubound=500000
keep 			`var' regnor year industry2 taxableinc location_code
g 				double z0=`var'
g 				z1=F1.`var'
g 				logchange=log(z1/z0)
keep 			if z0>80000 & z0<=500000
qui				sum logchange,d
drop			if (logchange<r(p1) | logchange>r(p99)) & year<2011
g				logz0=log(z0)
g				tozero=(`var'<=350000)
g				nottozero=(`var'>400000)
g				treat=(tozero==1 | nottozero==1)

/* DD PLOT */

bys				year treat:egen avglogchange=mean(logchange)
bys				year treat:g index=_n
#d				;
twoway  		(connected  avglogchange year if  year<2011 & treat==1 & index==1,sort clcolor(red) clwidth(thick) mcolor(red) msymbol(O) msize(vlarge))
				(connected  avglogchange year if  year<2011 & treat==0 & index==1,sort clcolor(midblue) clwidth(thick) mcolor(midblue) msymbol(S) msize(vlarge)),
				xtitle(Year) xtitle(, alignment(top)) 
				xline(2008.5, lcolor(black) lwidth(medthick) lpattern(longdash))
				ytitle(Average Log Change in Self-Employment Income) yscale(titlegap(*10))
				ylabel(-0.4(0.2)0.6)
				legend(region(style(none)) label(1 "Treatment") label(2 "Control") rows(1)) 
				graphregion(fcolor(white) style(none) color(white) margin(0 2 0 2)) bgcolor(white);
graph 			export "$project_graph\FigureAIV.eps", replace;
#d 				cr


				
